package com.oocl.work1_and_work2;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HomeWork2 {
	public static final String str = "中国的WD东西SJFKASKLJDsdsjkkjsad1298478329923,.!:";
	
	public int getSymbolNum(String str){
		String r = "\\p{P}";
		int count = 0;
		Pattern p = Pattern.compile(r);
		Matcher m1 = p.matcher(str);
		while(m1.find())
			count++;
		return count;
	}
	
	public int getChineseNum(String str){
		String r = "[\u4e00-\u9fa5]";
		int count = 0;
		Pattern p = Pattern.compile(r);
		Matcher m1 = p.matcher(str);
		while(m1.find())
			count++;
		return count;
	}
	public int getDigitNum(String str){
		String r = "\\d";
		int count = 0;
		Pattern p = Pattern.compile(r);
		Matcher m1 = p.matcher(str);
		while(m1.find())
			count++;
		return count;
	}
	public int getCharaterNum(String str){
		String r = "[a-zA-Z]";
		int count = 0;
		Pattern p = Pattern.compile(r);
		Matcher m1 = p.matcher(str);
		while(m1.find())
			count++;
		return count;
	}
	
	public static void main(String[] args) {
		HomeWork2 work2 = new HomeWork2();
		System.out.println(work2.getDigitNum(str));
		System.out.println(work2.getCharaterNum(str));
		System.out.println(work2.getChineseNum(str));
		System.out.println(work2.getSymbolNum(str));
	}
}
